﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace Nextensions.GUI
{
    public class SelectableList: ListBox
    {
        /*
        private List<string> _items = new List<string>(256);
        private Brush _textBrush;
        private int _textHeightIncr;

        public SelectableList()
        {
            _textBrush = new SolidBrush(ForeColor);
        }

        protected override void InitLayout()
        {
            base.InitLayout();
            _textHeightIncr = (int)Graphics.FromHwnd(Handle).MeasureString("A", Font).Height;
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            PointF textLoc = new PointF(0, 0);

            for (int i = 0; i < Items.Count; i++)
            {
                e.Graphics.DrawString(Items[i], Font, _textBrush, textLoc);
                textLoc.Y += _textHeightIncr;
            }
        }

        public List<string> Items
        {
            get
            {
                return _items;
            }
        }

        public void AddItem(string Item)
        {
            _items.Add(Item);
            CalculateSize();
        }

        private void CalculateSize()
        {
            if (Items.Count == 0)
            {
                Size = new Size(0, 0);
                return;
            }

            Graphics g = Graphics.FromHwnd(Handle);
            SizeF s = g.MeasureString(Items[0], Font);
            float width = s.Width, height = s.Height;

            for (int i = 1; i < Items.Count; i++)
            {
                SizeF s1 = g.MeasureString(Items[i], Font);
                
                width   = Math.Max(width, s.Width);
                height  = Math.Max(height, s.Height);
            }

            Size = new Size((int)Math.Round(width), (int)Math.Round(height));
        }
         */
    }
}
